#include <bits/stdc++.h>
using namespace std;

void solve() {
    int n;
    cin >> n;
    int ans = 0, t = 0;
    for(int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        if(a <= 10) {
            if(b < ans) {
                ans = b;
                t = i + 1;
            }
        }
    }
    cout << t << endl;
}

int main() {
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}